package com.miracle.schedule.web.controller;

import com.miracle.schedule.web.service.ScheduleService;
import com.miracle.schedule.web.task.TestTriggerTask3;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Author zht
 * @Date 2021/11/1 15:22
 * @Version 1.0
 */

@RestController
@RequestMapping(ScheduleController.PATH)
public class ScheduleController {
    private static final Logger log = LoggerFactory.getLogger(ScheduleController.class);
    public static final String PATH = "/schedule/testSchedule";

    @Resource
    ScheduleService scheduleService;

    @GetMapping("add")
    public String addSchedule(String taskId, String taskBean, String cron) throws InterruptedException {
        return scheduleService.addSchedule(taskId,taskBean,cron);
    }

    @GetMapping("edit")
    public String editSchedule(String taskId, String taskBean, String cron) throws InterruptedException {
        return scheduleService.editSchedule(taskId,taskBean,cron);
    }

    @GetMapping("cancle")
    public String cancleSchedule(String taskId) throws InterruptedException {
        return scheduleService.cancleSchedule(taskId);
    }
}
